package com.bawei.property.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import com.bawei.property.databinding.ItemCarColorBinding
import com.bawei.property.entity.CarColorValues
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * Author: Jason Zhang
 * Date: 2024/6/4
 * Desc:
 */
class CarColorAdapter constructor(private val layoutId: Int) : BaseQuickAdapter<CarColorValues, CarColorAdapter.ItemViewHolder>(layoutId){

    inner class ItemViewHolder(val binding: ItemCarColorBinding): BaseViewHolder(binding.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
        var itemBinding = DataBindingUtil.inflate<ItemCarColorBinding>(LayoutInflater.from(parent.context), layoutId, parent, false)
        return ItemViewHolder(itemBinding)
    }

    override fun convert(holder: ItemViewHolder, item: CarColorValues) {
        holder.binding.entity = item
        holder.binding.executePendingBindings()
    }
}